import {
	removeStore,
	setStore
} from '@/utils/tools';
import {
	FALSE
} from 'sass';

const state = {
	token: '',
	personalInfoData: {}, //个人所有信息
	siteName: '临沂市',
	areaId: '',
	siteLevel: '',
	menuList: [],
	searchView: false,
	searchMiniView: false,

}

const mutations = {
	//登录后存储 token
	SET_TOKEN: (state, data) => {
		state.token = data
		setStore('token', data)
	},
	//退出后删除 token
	REMOVE_TOKEN: (state, token) => {
		state.token = null;
		removeStore('token')
	},
	SET_SEARCHE: (state, token) => {
		state.searchView = true;

	},
	REMOVE_SEARCHE: (state, token) => {
		state.searchView = false;

	},
	SET_MINISEARCHE: (state, token) => {
		state.searchMiniView = true;
	
	},
	REMOVE_MINISEARCHE: (state, token) => {
		state.searchMiniView = false;
	
	},
	//个人信息  存入
	SET_PERSONALINFO_DATA: (state, data) => {
		state.personalInfoData = data;
	},
	//个人信息  删除
	REMOVE_PERSONALINFO_DATA: (state, data) => {
		state.personalInfoData = null;
	},

	//设置主站名称
	SET_LOCATION_NAME: (state, data) => {
		state.siteName = data
	},
	//删除 主站名称
	REMOVE_LOCATION_NAME: (state, token) => {
		state.siteName = null;
	},

	//设置主站code
	SET_LOCATION_ID: (state, data) => {
		state.areaId = data
	},
	//删除 主站code
	REMOVE_LOCATION_ID: (state, token) => {
		state.areaId = null;
	},

	//设置主站level
	SET_LOCATION_LEVEL: (state, data) => {
		state.siteLevel = data
	},
	//删除 主站level
	REMOVE_LOCATION_LEVEL: (state, token) => {
		state.siteLevel = null;
	},

	//存储导航menu
	SET_MENU_LIST: (state, data) => {
		state.menuList = data
	},
	//存储导航menu
	REMOVE_MENU_LIST: (state, data) => {
		state.menuList = []
	},
}

const actions = {
	setToken({
		commit
	}, data) {
		commit('SET_TOKEN', data)
	},

	setMiniSearche({
		commit
	}, data) {
		commit('SET_MINISEARCHE', data)
	},
	removeMiniSearche({
		commit
	}, data) {
		commit('REMOVE_MINISEARCHE', data)
	},

	setSearche({
		commit
	}, data) {
		commit('SET_SEARCHE', data)
	},
	removeSearche({
		commit
	}, data) {
		commit('REMOVE_SEARCHE', data)
	},
	removeToken({
		commit
	}, data) {
		commit('REMOVE_TOKEN', data)
	},
	//个人中心 - 个人信息
	setPersonalInfoData({
		commit
	}, data) {
		commit('SET_PERSONALINFO_DATA', data);
	},
	removePersonalInfoData({
		commit
	}, data) {
		commit('REMOVE_PERSONALINFO_DATA', data);
	},
	//设置主站名称
	setLocationName({
		commit
	}, data) {
		commit('SET_LOCATION_NAME', data)
	},
	removeLocationName({
		commit
	}, data) {
		commit('REMOVE_LOCATION_NAME', data)
	},
	//设置主站code
	setLocationId({
		commit
	}, data) {
		commit('SET_LOCATION_ID', data)
	},
	removeLocationId({
		commit
	}, data) {
		commit('REMOVE_LOCATION_ID', data)
	},
	//设置主站level
	setLocationLevel({
		commit
	}, data) {
		commit('SET_LOCATION_LEVEL', data)
	},
	removeLocationLevel({
		commit
	}, data) {
		commit('REMOVE_LOCATION_LEVEL', data)
	},
	setMenuList({
		commit
	}, data) {
		commit('SET_MENU_LIST', data)
	},
	removeMenuList({
		commit
	}, data) {
		commit('REMOVE_MENU_LIST', data)
	}
}


export default {
	state,
	mutations,
	actions,
}